package
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import sangpil.pv3d.CubeEffect;
	import sangpil.pv3d.RotatingEffect;
	import sangpil.pv3d.events.CubeEvent;
	import sangpil.pv3d.events.RotatingEvent;

	[SWF(width = 760, height = 405, frameRate = 30, backgroundColor = 0x000000)]
	public class CubeTester2 extends Sprite
	{
		private var t1:tempRect02;
		private var t2:tempRect03;
		private var temp:CubeEffect;
		private var temp2:RotatingEffect;
		public function CubeTester2()
		{
			super();
			t1 = new tempRect02();
			t2 = new tempRect03();
			this.addChild(t1);
			t1.whiteBtn.buttonMode = true;
			t2.whiteBtn.buttonMode = true;
			t1.addEventListener(MouseEvent.MOUSE_DOWN, addTween);
		}
		
		private function addTween(e:MouseEvent):void
		{
			temp = null;
			temp = new CubeEffect(t1, t2, 'right');
			this.removeChild(t1);
			temp.addEventListener(CubeEvent.COMPLETE, changed);
			this.addChild(temp);
		}
		
		private function changed(e:CubeEvent):void
		{
			this.removeChild(temp);
			this.addChild(t2);
			this.t2.addEventListener(MouseEvent.MOUSE_DOWN, addRotation);
		}
		
		private function addRotation(e:MouseEvent):void
		{
			this.temp2 = null;
			this.temp2 = new RotatingEffect(t2, t1, t2.width, t2.height, 'left', 20, 1);
			this.removeChild(t2);
			this.temp2.addEventListener(RotatingEvent.COMPLETE, goFirst);
			this.addChild(this.temp2);
		}
		
		private function goFirst(e:RotatingEvent):void
		{
			this.removeChild(this.temp2);
			this.addChild(t1);
		}
	}
}